<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;


class Ad extends Model
{
    protected $table = "ad";

    public function ad_position()
    {
        return $this->belongsTo(AdPositionId::class, 'ad_position_id');
    }

    public static function getHref($ad)
    {
        $href = $ad->href;

        $href = str_replace("{url}", config('wx.web_host'), $href);

        return $href;
    }

    //{"default":"navigateTo","options":{"navigateTo":"navigateTo","redirectTo":"redirectTo","switchTab":"switchTab","navigateBack":"navigateBack","scanLogin":"扫码登录"}}
    const EVENT = [
        'navigateTo' => 'navigateTo',
        'redirectTo' => 'redirectTo',
        'switchTab' => 'switchTab',
        'navigateBack' => 'navigateBack',
        'scanLogin' => '扫码登录'
    ];
}
